<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" >
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>layout 后台大布局 - Layui</title>

    <link rel="stylesheet" th:href="@{/layui/css/layui.css}">
    <i th:replace="~{common :: baseUrl}"></i>
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">



    <form class="layui-form layui-form-pane" action="">


        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">采购编号</label>
                <div class="layui-input-inline" style="width: 250px">
                    <input type="text" readonly id="id" name="id" th:value="${purchaseOrders.id}"  autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline" >
                <label class="layui-form-label">审核状态</label>
                <div class="layui-input-inline" >
                    <input type="text" readonly name="statusString" th:value="${purchaseOrders.statusString}" autocomplete="off" class="layui-input">
                </div>
            </div>

        </div>

        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">采购门店</label>
                <div class="layui-input-inline">
                    <select name="merchantsId" id="merchantsId" disabled>
                        <option th:each="l : ${merchantsInformationList}" th:value="${l.id}" th:text="${l.name}" th:selected="${l.id == purchaseOrders.merchantsId}">无</option>

                    </select>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">经办人员</label>
                <div class="layui-input-inline">
                    <input type="text" readonly name="operator" th:value="${purchaseOrders.operator}" autocomplete="off" class="layui-input">
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-block">
                <input type="text" readonly name="remark" th:value="${purchaseOrders.remark}" autocomplete="off" placeholder="请输入备注" class="layui-input">
            </div>
        </div>


        <!--展示数据-->
        <div>

            <table class="layui-hide" id="purchaseOrders" lay-filter="purchaseOrders" ></table>

            <!--        表格右侧操作栏-->
            <script type="text/html" id="barDemo">
                <button class="layui-btn  layui-btn-sm layui-btn-primary" lay-event="del"><i class="layui-icon layui-icon-close"></i></button>
            </script>

        </div>




        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">制单人</label>
                <div class="layui-input-inline" style="width: 70px;">
                    <input type="text" readonly name="preparedBy" th:value="${purchaseOrders.preparedBy}"  autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">制单日期</label>
                <div class="layui-input-inline" style="width: 150px" >
                    <input type="text" readonly name="preparedDate" th:value="${purchaseOrders.preparedDate}" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">审核人</label>
                <div class="layui-input-inline" style="width: 70px;">
                    <input type="text" readonly id="verifier" name="verifier" th:value="${purchaseOrders.verifier}"  autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">审核日期</label>
                <div class="layui-input-inline" style="width: 150px" >
                    <input type="text" readonly id="verifierDate" name="verifierDate" th:value="${purchaseOrders.verifierDate}" autocomplete="off" class="layui-input">
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="button" id="return" class="layui-btn ">返回</button>
                <button type="button" class="layui-btn" lay-submit="" lay-filter="sub">审核</button>

            </div>
        </div>



    </form>


</div>
<script th:src="@{/layui/layui.js}"></script>
<script th:inline="none">
    //JavaScript代码区域
    layui.use(['element','table','form'], function(){
        var element = layui.element;
        var table = layui.table;
        var form = layui.form;
        var $ = layui.$;



        //表格初始化
        table.render({
            elem: '#purchaseOrders'
            ,url:baseUrl+'purchase/orders/ordersList'
            ,cellMinWidth: 80 //全局定义常规单元格的最小宽度，layui 2.2.1 新增
            ,width: 1200
            ,totalRow: true
            ,cols: [[
                {field:'materialId', width:80, title: '原料ID',hide:true}
                ,{field:'id', width:80, title: 'ID',hide:true}
                ,{field:'name', width:100, title: '原料名称' , totalRowText: '合计'}
                ,{field:'nowRepertory', width:100, title: '当前库存' }
                ,{field:'repertoryUnit', width:100, title: '库存单位' }
                ,{field:'purchaseUnit', width:100, title: '采购单位' }
                ,{field:'conversionName', width:100, title: '规格换算' }
                ,{field:'unitPrice', width:100, title: '采购进价' }
                ,{field:'purchaseNum', width:100, title: '采购数量'}
                ,{field:'subtotalString', width:100, title: '小计' ,totalRow: true  }
                ,{field:'remark', width:100, title: '备注' }
            ]]
            ,where: {
            id:$("#id").val(),


        } //设定异步数据接口的额外参数

    });








        //取消
        $("#return").click(function (){

            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
            parent.layer.close(index); //再执行关闭


        });




        //添加
        form.on('submit(sub)', function(data){


            layer.open({
                title: '编辑'
                ,content: baseUrl+'purchase/orders/auditStatus-ui?id='+$("#id").val()
                ,type:2
                ,area: ['800px', '650px']
                ,closeBtn:1
                ,end:function () {

                    var localTest = layui.sessionData('audit');
                    var purchaseOrders = localTest.purchaseOrders;

                    if (purchaseOrders!=null && purchaseOrders!='') {
                       $("#verifier").val(purchaseOrders.verifier);
                       $("#verifierDate").val(purchaseOrders.verifierDate);

                        //移除sessionStorage 的缓存
                        layui.sessionData('audit', {
                            key: 'purchaseOrders'
                            ,remove: true
                        });
                    }
                }

            })

        });








    });
</script>
<script>

</script>
</body>
</html>
